package net.cyndeline.entitySystem.common

import net.cyndeline.entitySystem.EntityRef
import net.cyndeline.entitySystem.Component
import net.cyndeline.entitySystem.Event
import net.cyndeline.entitySystem.defaultImpl.DefaultEntityManager
import net.cyndeline.entitySystem.IdManager
import net.cyndeline.entitySystem.EntityManager

class NullEntityRef extends EntityRef {
  
  override def exists = false
  override def hasComponent(componentClass: Class[_ <: Component]) = false
  override def getComponent[T <: Component](componentClass: Class[T]): Option[T] = None
  override def addComponent[T <: Component](component: T): Option[T] = None
  override def removeComponent(componentClass: Class[_ <: Component]): Unit = {}
  override def iterateComponents: Iterator[Component] = new NullIterator
  override def destroy = {}
  override def send(event: Event) = {}
  override def id: Int = IdManager.NULL_ID
  def id_=(setId: Int) = {}
  def entityManager_=(manager: EntityManager) {}
  def entityManager = null
  override def toString = "EntityRef {id=" + IdManager.NULL_ID + "}"
  
  override def equals(o: Any) = {
    if (this == o) true
    
    o match {
      case er:EntityRef => !er.exists
      case null => true
      case _ => false
    }
  }
  
  override def hashCode = 0
  override def invalidate = {}
  override def copy = this
}